Fix stray bin folder race on deleted .classpath (partial fix for flaky MavenProjectMetadataFileTest) - #3840
Closed
chagong wants to merge 1 commit into
Closed
Conversation
StandardProjectsManager.fileChanged() called JDTUtils.getFileOrFolder(), which eagerly refreshes the resource tree, before IBuildSupport.refresh() had a chance to recover the classpath for a DELETED .classpath event. This notified JDT Core's classpath machinery that the file was gone before the recovery logic ran, causing JDT Core to briefly fall back to a default classpath and create a stray bin output folder. Resolve deleted .classpath files via JDTUtils.findFile() instead, which does not perform the premature refresh; IBuildSupport.refresh() already performs the equivalent refresh once the classpath has been restored. Fixes the stray-bin-folder root cause behind the long-standing flaky MavenProjectMetadataFileTest failures. See eclipse-jdtls#1443 and eclipse-jdtls#1251. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes one confirmed root cause behind the long-standing flaky
MavenProjectMetadataFileTestfailures (e.g. seen in #3839's CI): a race betweenStandardProjectsManager.fileChanged()'s eager resource refresh andIBuildSupport.refresh()'s classpath recovery logic forDELETED.classpathevents.Root cause
fileChanged()calledJDTUtils.getFileOrFolder(uriString), which eagerly callsIContainer#refreshLocal(DEPTH_ONE, null). For a deleted.classpathfile, this notifies JDT Core's classpath machinery that the file is gone beforeIBuildSupport.refresh()gets a chance to recover/regenerate the correct classpath. In that window, JDT Core briefly falls back to a default classpath and creates a straybinoutput folder — which is exactly the symptom asserted against inMavenProjectMetadataFileTest#testDeleteClasspath.This matches long-standing reports in #1443 and #1251.
Fix
Resolve deleted
.classpathfiles viaJDTUtils.findFile()instead, which does not perform the premature refresh.IBuildSupport.refresh()already performs the equivalent (and correctly ordered) refresh once it has restored the classpath.Verification
Reproduced locally via:
Confirmed this change eliminates the stray-
bin-folder assertion failure, reproducibly across multiple runs.Note: second, deeper issue remains
While investigating, I found a second, unrelated root cause affecting
testMetadataFileSyncand part oftestDeleteClasspath— an EFS-redirect/resource-tree synchronization gap inorg.eclipse.jdt.ls.filesystem(active whenjava.import.generatesMetadataFilesAtProjectRoot=false). I've documented detailed findings (including instrumented trace evidence fromeclipse.jdt.core) in a follow-up issue rather than bundling an unverified fix here, since it needs live debugging to pin down precisely. This PR only contains the confirmed, verified fix.